<?php
namespace Pay\Controller;
use \Common\Controller\BaseController;
class IndexController extends BaseController
{
	public function _initialize(){
		header("Content-type:text/html;charset=utf-8");//保证字符编码为utf8
		parent::_initialize();
		$this->db = D('Order');
		$this->member_db = D('Member');
	}

    /* 发起支付请求 */
    public function index() {
        $product_info = array(
            'name' => '积分充值',
            'trade_sn' => '2014032',
            'total_fee' => '0.01'
        );
        $payment_handler = new \Pay\Factory\Factory('alipay');
        $payment_handler->set_productinfo($product_info);
        $result = $payment_handler->get_code();
        echo "<a href='".$result."' target='_blank'>go...</a>";
    }

    /* 处理支付结果 */
    public function callback() {
        $payment_handler = new \Pay\Factory\Factory('alipay');
        $result = $payment_handler->notify();
        if ($result !== FALSE) {
            // $this->success('支付完成');
           include 'file'; 
        } else {
            $this->error('支付失败，请联系管理员');
        }
    }

}